#!usr/bin/env python
# -*- coding:utf-8 _*-
"""
@author:zhengxin
@file: 001_algorithm.py
@time: 2024/12/10  14:56
# @describe:
"""

""" 题目001：有四个数字：1、2、3、4，能组成多少个互不相同且无重复数字的三位数？各是多少？"""

# 解法一
def tm001():
    arr = []
    for i in range(1, 5):
        for j in range(1, 5):
            for k in range(1, 5):
                num = 100*i + 10*j + k
                if i!=j and j!=k and i!=k and num not in arr:
                    arr.append(num)
    print(len(arr), arr)

tm001()



# 解法二, 使用 python自带排列组合模块-- itertools
import itertools

temp_arr = list(itertools.permutations([1, 2, 3, 4], 3))    # 排列 A_4^3 = (4)!/(4-3)! = (4*3*2*1)/1 = 24
arr = [100*t[0]+10*t[1]+t[2] for t in temp_arr]
print(len(arr), arr)
